Digital filter for random variable

ABSTRACT

A digital filter for use with a randomly generated variable, such as in a radioactive densometer, is provided and includes a microprocessor and timing clock for sampling the random variable over a specific time interval. The microprocessor utilizes a weighting factor based upon a first confidence factor and computes the mean value of a first sample of the random variable and compares the number of standard deviations that a subsequent sample is from the mean value of the previous sample and uses a probability related factor to determine if the subsequent sample represents an actual change in density. Further, the microprocessor uses a second confidence factor in determining the weighting factor which counts the number of consecutive times that the subsequent samples are greater than, or less than the mean value and again determines a probability related factor to determine if a change in density is actually occurring. As both the first and second confidence factors increase, so does the weighting factor and the probability that an actual change in fluid density has occurred.

BACKGROUND OF THE INVENTION

A major portion of the services provided by the oil field serviceindustry relate to cementing operations, including primary cementing,that is, cementing casing into a well bore by pumping cement slurry downa centralized casing and up into the annulus between the well bore andthe casing, and squeeze cementing of a particular zone or interval.Additionally, cement slurry is often pumped downhole for water control,fluid loss control, and many other purposes.

Another aspect of the oil field service industry is stimulation serviceswhich include, among other operations, fracturing an oil bearingformation by pumping a pressurized fluid into well bore perforationsuntil the oil bearing formation fractures. A proppant laden slurry isthen pumped down hole after the fracturing fluid. This fracture is thenheld open by the proppant, usually sand or bauxite, which remainsembedded in the walls of the fracture after the fluid contained withinthe slurry migrates into the surrounding formation, or, ideally, isflowed back into the well bore out of the formation when pressure isreduced.

In all of the aforementioned situations it would be advantageous to havea quick-response system for determining the density of the cementslurry, or the proppant slurry.

In oil well cementing operations, the density of the cementing slurry isan important factor. The bore hole cementing fluid typically is a slurryof chemical constituents mixed with water and has a certain density.Should the composition of the slurry mixture change during the pumpingoperation, the density obviously changes and a change in mixture canaffect desired results in the cementing operation. For that reason, itis desirable to be able to sense changes in density, i.e. changes in themixture and to be able to provide a correction to the mixture before alarge volume of incorrect mixture is introduced into the system.

Similarly, in fracturing of wells, monitoring of the density of thefracturing fluid, or proppant slurry, is desirable to ensure that thereis not too little proppant in the slurry, which can result in fractureclosure, or too much proppant, which can result in "sand out", ortermination of the operation due to plugging of the pump, lines or wellbore with proppant.

It is accordingly, a feature of the present invention to obtain arelatively quick-response time to the change of density in a cementingor fracturing fluid system so that the fluid may be continuouslymonitored and corrected if necessary to obtain a consistent density forthe fluid mixture.

The present invention relates to a method and apparatus for processingrandomly generated data to obtain quick response control to changes inthe density of a fluid.

The prior art has developed digitally processed data for nucleardensometers, as illustrated by U.S. Pat. No. 3,657,532, issued to CarlW. Zimmerman. As set forth in the '532 patent, digital systems allow theincorporation of extremely reliable, inexpensive and compact integratedcircuits and can be used to develop digital pulse counting techniques.However, in this prior art apparatus, there remains a substantially longtime response to a change in density in the fluid sample being tested,and as a consequence, a considerable volume of incorrect density fluidmay be passed through the system for use before a correction in thedensity can be detected or made.

Also, U.S. Pat. No. 4,618,939 to Davis and assigned to the assignee ofthe present invention involves a method and system for sensing thedensity of a fluid and for providing statistical count signals which areproportional to density. This prior art system only identifiessignificant changes in density and then responds to these changes onlyafter a substantial period of time.

SUMMARY OF THE INVENTION

A filter for use in a central processing unit (CPU) is provided whichcan quickly detect actual changes in the state of randomly generateddata samples. For example, a radioactive source provides randomemissions, some of which are absorbed by the fluid to be measured. Theremaining emissions produce counts which are inversely proportional tothe density of the fluid. The present invention provides an extremelyaccurate and quick means of determining whether a change in state (suchas density) has actually occurred. The CPU is programmed such that asingle deviation of counts with a large number of standard deviations,or multiple deviations of counts with a small or large number ofstandard deviations in succession having the same sign around the meanwill quickly determine when an actual change in state has occurred andupdate a weighting factor accordingly.

Therefore, in accordance with the previous summary, objects, featuresand advantages of the present invention will become apparent to oneskilled in the art from the subsequent description and the appendedclaims taken in conjunction with the accompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a schematic block diagram depicting a radioactive densometersystem which can utilize the present invention;

FIG. 2 is a graph illustrating density with respect to count rate;

FIG. 3 is a graph representing the normal distribution function of therandom counts under steady state conditions.

FIGS. 4a and 4b are flow charts for use with a microprocessor, toprocess the data for obtaining fast response times and indications tochanges in state of randomly generated signals.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

Referring now to FIG. 1, use of the invention in the context ofcementing a well bore is described. A housing 10 is mounted on a tubularpipe with a bore 12 through which a well cementing fluid 13 is caused toflow between cementing tanks or trucks (not shown) and a well bore to becemented (not shown). A source of radiation 14 is located on one side ofthe bore 12 and, on an opposite side, a radiation detector 15 islocated. The radiation provided by the source 14 is a constant intensityover a long period of time (random intensity over a finite period) ofgamma ray emissions. The gamma rays are transmitted through the materialsurrounding the bore 12, the slurry of cement 13 within the bore and tothe detector 15. The detector 15 may be, for example, a crystal ofsodium or cesium iodide (thallium activated) or other material capableof scintillating under irradiation and may include an electron photomultiplier tube for converting light flashes of the scintillation of thecrystal into an electrical pulse. As will be apparent, the only variablewith respect to density between the source 14 and detector 15 is thecement slurry 13. A percentage of the gamma rays emitted by the source14 are absorbed or attenuated by the cement slurry 13 and do not reachthe detector 15. Thus the counting rate of the output signal from thephoto multiplier tube of the detector 15 is similarly related to thedensity of cement slurry 13 through which the rays must pass to reachthe crystal in the detector 15 and the intensity of the source 14.

The detector 15 is powered by a high voltage power supply 16 and theoutput signals from the detector 15 are supplied to a comparator circuit17. The comparator circuit 17 eliminates extraneous noise signals belowa selected amplitude level determined by a reference level set bypotentioner 17A, and amplifies the output signals which are passedthrough the circuit. The output of the comparator circuit 17 representscount pulses above the threshold level set by the comparator 17.

The output signals from the comparator 17 are applied to a counterregister 25 and the counter register 25 outputs to a computer 26. Thecomputer may be a ZYLOG 16 Bit microprocessor or other suitable CPU. Thecounter register 25 is keyed by a clock 49 to systematically andregularly process the counts in the register 25 to the computer 26. Thecomputer 26, upon processing of the data, provides an output to arecorder 27.

Before detailing the present invention with respect to processing ofdata by the computer 26, some background information may be helpful toan understanding of the present invention.

The number of pulses detected by the detector 15 may be shown to be:

    N=Sr.sub.1. . .

Where N is the number of pulses counted during a time period S forrandomly generated pulses from a detector and where the counting rate r₁is related to the density of material.

For a fluid material having a given density, the following relationshipexists:

    N=KIe.sup.-αt. . .

Where N is the number of pulses detected; K is a constant; Ie⁻αt is theactivity of the source at time "t" for a decay factor α.

The intensity I may also be stated to be:

    I=I.sub.k .sup.-K/D(u/D). . .

Where u/D is the mass absorption coefficient of the substance of thebore, I_(k) is the radiation intensity at the detector with the boreempty, K is a constant dependent upon the width of the bore and D equalsthe density of the fluid material.

Rewriting the last equation above gives the following: ##EQU1##

A plot of the counting rate versus density is illustrated by the curve18 in FIG. 2.

In the operation of the present invention, the detected counts areprocessed by the comparator 17 and output to the count register 25 andsubsequently to the computer 26 on a periodic basis. So long as thedensity of the slurry is constant, as shown by the vertical line 28 inFIG. 2, the count rate signal is processed using a relatively smallweighting factor. However, if there is a large change in density, or ifsmall, or large, changes occur consecutively without a change in sign, alarge weighting factor is used to process the count rate signal. Thecomputer 26 samples the accumulated counts signals each tenth of asecond, based upon the output of clock 49, and develops a weightingfactor. The weighting factor is a function of the change in density ofthe slurry and if large changes of density occur for a sufficient periodof time, or if smaller changes of density occur for a longer period oftime consecutively without a change of sign, then the weighting factoris changed to provide a faster indication of the change in density byapproximately a factor of ten (or one order of magnitude) than ispossible with the filter disclosed by U.S. Pat. No. 4,618,939.

The digital filter of the present invention is described herein withrespect to a radioactive densometer, however, it should be noted thatthe filter is applicable to any system wherein data is randomlygenerated, such as in many types of well logging.

The present invention greatly reduces response time to an actual changein state of the density by filtering out the unusual random data fromthe data which indicates that an actual change has occurred and thattherefore the weighting factor must be increased to quickly reflect achange in state, such as fluid density.

Initially, the filter determines the mean value of the frequency of thecounts received, which is shown as M on FIG. 3. The horizontal axis ofFIG. 3 represents the number of standard deviations from the mean of thecounts. The vertical axis of FIG. 3 represents the probability ofoccurrence. In other words, FIG. 3 is an illustration of the normaldistribution function.

The filter of the present invention uses a combination of two confidencefactors in order to obtain a weighting factor.

The first confidence factor uses the probability of random occurrence ofstatistical deviations relative to the standard deviation. For example,the greater the distance (number of standard deviations) between themean and the sampled data, the greater the confidence factor. Statedanother way, the more standard deviations away from the mean value, thegreater the confidence that an actual change in state has occurred.Thus, the weighting factor can be raised as the probability of randomoccurrences decreases, (i.e. confidence increases).

The second confidence factor uses the fact that the probability of thedeviation being either positive or negative is 50 percent over a finiteperiod if no change in state has occurred. That is, randomly generateddata is just as likely to be positive (greater than the mean) asnegative (less than the mean). Also, for long periods of time, thedeviations must be positive, and negative 50 percent of the time. Thus,the more consecutive positive, or negative deviations that occur, thehigher the confidence factor that an actual change in state hasoccurred. Therefore, the weighting factor can be increased since theconfidence in the reading has increased.

The mean, as shown on FIG. 3, is changed each time action is taken. Thegreater the confidence (and thus the greater the weighting factor) themore drastic is the action to be taken. For example, if consecutive datasamples are received with three or more positive standard deviationsfrom the mean, then the confidence is high, because the sign of the datahas been consecutively positive and three or more standard deviationsaway from the mean. Thus, fairly drastic action would be taken to changethe mean to correspond to the newly received data.

However, if the new data had signs which alternated between positive andnegative, and were less than 0.6 standard deviations from the mean, thensmall action would be taken (i.e. the mean would slowly approach the newdata), because the confidence that a change in state has occurred isvery low.

As the deviation of the new data approaches zero number of standarddeviations from the mean value, there is a low probability that thereceived data represents an actual change in state of the density. Aspreviously noted, this probability increases as more consecutivelypositive, or negative data and an increasing number of standarddeviations away from the mean is received.

The actual steps which represent filter program to be input to CPU 26and utilized with the present invention are shown in FIGS. 4a and 4b.

The following variables are used throughout the program:

M mean

SR service request

W determines if first time through filter

A digital value (count)

S difference of current value (count) and the mean

U used to show sign of present S

V used to show sign of previous S

α square root of mean (standard deviation)

T absolute value of the number of standard deviations between the meanand the current value

N consecutive number of times that the sign of S did not change (unlessthe weighting factor equals 99)

B weighting factor

At step 1, W is set to zero, V is set to one and N is set to zero. Step2 determines if SR is equal to one indicating that clock 49 hasinitiated a 0.1 second sampling period. If not, then the system returnsto the beginning of step 2. If SR is equal to one, then at step 3 thedigital value of the radioactive densometer is read.

Step 4 determines if this is the first time through the filter. If so,then at step 5, the counts (A) are designated as the mean (M). If thisis not the first time through the filter then W and U are set equal toone (step 6).

Step 7 determines S, i.e. the difference between the mean and countsbeing processed. Next, at step 8, the filter determines whether S isgreater than or equal to zero. If so, the system proceeds to step 10where the standard deviation of the mean is determined. If, at step 8, Sis not greater than or equal to zero, then step 9 sets U, the variableused to show the sign of S, to two.

After the standard deviation is determined, the filter calculates T, theabsolute value of the ratio of the difference between the mean and thecounts to the standard deviation of the mean (step 11). Next, thepresent sign of S is compared to the previous sign of S (step 12) and ifnot equal the system continues to step 13. Step 13 sets the consecutivenumber of times (N) that the sign did not change to one, and sets avariable P=0.5. P can be used to vary B by the function of P times N andprovides more drastic action as the confidence level is increased, i.e.upon consecutive entry of the data into either a positive or negativezone around the mean. After step 13, the filter proceeds to step 26,discussed below.

If at step 12 U is equal to V, then step 14, adds one to the number ofconsecutive times in which the sign of S did not change.

Steps 15, 17, 19, 21 and 23 determine which band (number of standarddeviations the current value is from the mean) the current value is in.Steps 16, 18, 20, 22 and 24 set P to a specific value dependent upon theband and it should be noted that P can only have one value each time aset of data is processed through the loop of the filter. For example, ifT is greater than 0.6 (step 15), and if T is less than 1.9 (step 17)then P=1.1 (step 18).

Once a value is assigned to P in one of the steps 13, 16, 18, 20, 22 and24, the filter proceeds to step 26 where the weighting factor B isdetermined by multiplying the value of P (determined by one of the steps12, 15, 17, 19, 21 and 23) by the consecutive number of times the signof S did not change. Step 27 determines if B is greater than 20. If so,step 28 sets B equal to 20 and the system proceeds to step 29. If, atstep 27, B is not greater than 20, then the filter goes directly to step29 which determines if B is less than one. If B is less than one, thenstep 30 sets B equal to one and the filter continues to step 31. If B isnot less than one at step 29 then the system proceeds directly to step31.

Steps 27 and 28 are included to slow down the action the filter istaking in order to account for the possibility of an extremely errantrandom count. Steps 29 and 30 set the minimum action to a value of onein order to ensure that some type of action is always taken. Forexample, if T is approaching four, at step 23, and the sign has remainedconstant for a consecutive number of times, such as five, then thefilter would take drastic action if step 28 did not slow it down andassign the value 20.

If at step 23, T is greater than four then the filter presumes (at step25) that, for all practical purposes, a change has most certainlyoccurred and assigns the value of 99 to B and sets N equal to zero,before proceeding to step 31. By setting N equal to zero the action isslowed for the next time period (second confidence factor is decreased)since the number of times the sign of S did not change for the presentset of data will not carry over to the data for the next successive timeperiod.

Step 31 actually determines the type of action the system will take. Theprevious sign (V) of S is set to be equal to the present sign (U) of Sand the new mean (Mn) is determined by the following equation: ##EQU2##

Specifically, the new mean is determined by multiplying the weightingfactor percent [(B )/100] by the difference between the mean value ofthe previous sample and the current sample. This product is then addedto the current mean value, thereby determining the new mean value.

Therefore, it can be seen how the type of action to be taken by thesystem depends upon S and B, which are dependent upon the consecutivenumber of times the sign did not change, and the number of standarddeviations the count values are from the mean. When the new mean isdetermined, then the result is converted to a density representationprior to display on the recorder 27, at step 33.

Finally, after step 31, the filter loop ends at step 32 and step 34allows any other functions, or loops to be inserted and the system thenreturns to the beginning of step 2.

While this system is particularly adapted to the measurement of a cementor proppant slurry where extremely good resolution of densitymeasurement is required along with good accuracy and high stability,other adaptations and advantages of the invention will be readilyapparent to one skilled in the art to which the invention pertains froma reading of the foregoing. It is accordingly intended that theforegoing description be illustrative only and that the scope of theinvention be limited only by the language, with a full range ofequivalents, of the appended claims.

What is claimed is:
 1. An apparatus utilized by a radiation detectionsystem comprising:tubular means for conveying a fluid therethrough; aradioactive source means, disposed adjacent said tubular means, foremitting radiation having random intensity over a relatively shortperiod of time and a constant intensity over a relatively long period oftime; detection means, disposed diametrically opposite said radiationsource means and adjacent said tubular means, for detecting saidradiation, and for converting said radiation into electrical signals,said radiation being absorbed by said fluid based upon a density thereofand the relationship of fluid density to radiation detected beinginversely proportional; timing means for sampling said electricalsignals for a specific time period; and computer means for processingsaid sampled electrical signals by filtering said electrical signals andby adjusting the present detected density value relative to the previousdensity value utilizing a weighting factor based upon a first confidencefactor and a second confidence factor which indicates that an actualchange in the density value has occurred.
 2. An apparatus according toclaim 1, wherein said computer means determines said first confidencefactor based upon a number of standard deviations of the differencebetween a mean value of electrical signals sampled for previous timeperiods and a value of electrical signals sampled for a current timeperiod, and said computer means determines said second confidence factorby counting the number of times that said samples of electrical signalsare consecutively greater than, or consecutively less than, said meanvalue.
 3. An apparatus according to claim 2 wherein said firstconfidence factor is directly proportional to the number of standarddeviations of the difference between said mean value and said currentsample of electrical signals.
 4. An apparatus according to claim 3wherein said second confidence factor is directly proportional to atotal number of times that said samples of electrical signals areconsecutively greater than, or consecutively less than, said mean value.5. An apparatus according to claim 4 wherein said weighting factor isdirectly proportional to both said first confidence factor and saidsecond confidence factor.
 6. An apparatus according to claim 5 whereinsaid weighting factor determines in what proportion said mean value ofsaid previous samples of electrical signals should be adjusted tocorrespond to said current sample of electrical signals.
 7. An apparatusaccording to claim 6, wherein the adjustment of said mean value isimplemented by multiplying said weighting factor, divided by 100, by thedifference between said mean value of said previous samples ofelectrical signals and said current sample of electrical signals, andadding the product to said mean value of said previous samples ofelectrical signals.
 8. A method for radiation detection, comprising thesteps of:providing a radioactive source which emits radiation havingrandom intensity over a relatively short time period and constantintensity over a relatively long time period; providing a detector,linearly aligned with said radioactive source, for detecting saidradiation; flowing a fluid of a certain density between said detectorand said radioactive source; detecting said radiation, the amount ofsaid radiation detected being inversely proportional to the density ofsaid fluid; converting said radiation into electrical signals; samplingsaid electrical signals over a certain period of time; and processingsaid sampled electrical signals by filtering said electrical signals inaccordance with a weighting factor based upon a first confidence factorand a second confidence factor, including:setting an initial mean valueequal to an initial sample of electrical signals taken during an initialtime period; calculating a standard deviation of a previously determinedmean value; determining said first confidence factor by calculating thenumber of standard deviations of difference between said previouslydetermined mean value and a current sample of electrical signals, saidfirst confidence factor being directly proportional to said number ofstandard deviations; determining said second confidence factor bycounting the number of consecutive times the signs of subsequent samplesof electrical signals are unchanged with respect to previouslydetermined mean values, said second confidence factor being directlyproportional to said number of consecutive times; calculating saidweighting factor in accordance with said first confidence factor andsaid second confidence factor; and calculating a new mean value basedupon said previously determined mean value and the magnitude of saidweighting factor, said calculated new mean value being inverselyproportional to the density of said fluid.
 9. A method according toclaim 8 wherein said step of calculating a new mean value isaccomplished by utilizing a linear equation.
 10. A method according toclaim 8 wherein said step of calculating the weighting factor includesthe step of reducing the magnitude of said weighting factor inaccordance with the likelihood that an errant sample of said electricalsignals has been taken.
 11. A method according to claim 8 wherein saidstep of determining said second confidence factor includes adding thenumber of consecutive times the sign of the difference of said sample ofelectrical signals did not change for the sample of electrical signalstaken during a present time period to the number of consecutive timesthe sign did not change for any subsequent time periods.
 12. Anapparatus for processing randomly generated signals used to monitor thedensity of a fluid, comprising: detection means for detecting saidrandomly generated signals; sampling means for sampling successivegroups of said signals over specific intervals of time; and computermeans for filtering said randomly generated signals and for determiningwhether an actual change in the density of the fluid has occurred, saidcomputer means comparing a mean value of previously sampled signals witha number of standard deviations of a current group of sampled signalsand counting the number of times that successive groups of sampledsignals remain consecutively greater than, or consecutively less than,said mean value.
 13. A system for processing random data,comprising:means for receiving said random data; means for sampling saidrandom data over discrete time periods; and means for processing saidsampled random data by filtering said random data and by adjusting amean value of previous samples of random data relative to a currentsample of random data utilizing a weighting factor based upon both afirst confidence factor and a second confidence factor which indicatethat an actual change in the state of said random data has occurred,wherein:said first confidence factor is based upon a number of standarddeviations between said mean value of said previous samples of randomdata and a value of said current sample of random data; and said secondconfidence factor is determined by counting the number of times thatsaid samples of random data are consecutively greater than, orconsecutively less than, said mean value.
 14. A system according toclaim 13 wherein said first confidence factor is directly proportionalto the number of standard deviations of the difference between said meanvalue of said previous samples of random data and said current sample ofrandom data.
 15. A system according to claim 14 wherein said secondconfidence factor is directly proportional to a total number of timesthat said samples of random data are consecutively greater than, orconsecutively less than, said mean value of said previous samples ofrandom data.
 16. A system according to claim 15 wherein said weightingfactor is directly proportional to both said first confidence factor andsaid second confidence factor.
 17. A system according to claim 16wherein said weighting factor determines in what proportion said meanvalue of said previous samples of random data should be adjusted tocorrespond to said current sample of random data.
 18. A system accordingto claim 17 wherein said adjustment of said mean value is implemented byconverting said weighting factor to a percentage, defining a product bymultiplying said percentage by the difference between said mean valueand said value of said present sample of random data, and adding saidproduct to said mean value.
 19. A method of detecting a change indensity of a fluid, comprising the steps of:(a) determining an initialmean value corresponding to density of the fluid at an initial time; and(b) determining subsequent mean values, including:(b1) detectingradiation transmitted through the fluid; (b2) creating a count inresponse to the detected radiation; (b3) subtracting the mean valuewhich has been last determined from said count to define a difference;(b4) determining whether said difference has a sign which is the same asthe sign of a previous difference used in determining said lastdetermined mean value; (b5) if the sign is different, providing apredetermined weighting factor; (b6) if the sign is the same, computinga weighting factor in response to the difference and the number ofconsecutive times the sign has remained the same; (b7) computing a newsubsequent mean value, including adding a percentage, defined by theweighting factor, of said difference to said last determined mean value,wherein a change in said new subsequent mean value from said lastdetermined mean value indicate a change in density of the fluid; and(b8) repeating said steps (b1) through (b8) to monitor repeatedly forchanges in density of the fluid.
 20. A method as defined in claim 19,wherein:said step (b) further includes computing a standard deviationfor said last determined mean value and computing a quotient by dividingsaid difference by said standard deviation; and said step (b6) includesselecting a value for a variable in response to said quotient andmultiplying said selected value by said number of consecutive times thesign has remained the same to define said weighting factor.
 21. A methodas defined in claim 20, wherein said step (b6) further includes limitingsaid weighting factor to a predetermined maximum.
 22. A method asdefined in claim 20, wherein said step (b6) further includes settingsaid weighting factor to a predetermined maximum in response to saidquotient exceeding a predetermined value.
 23. A method as defined inclaim 19, wherein said steps (b5) and (b6) include defining a minimumpositive value for said weighting factor.